<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" import="java.sql.*"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="ookweb.*"%>
<%request.setCharacterEncoding("UTF-8");  %>
<%@ include file="/head.jsp" %> 
<%
String dbuser = application.getInitParameter("dbuser");
String dbpass = application.getInitParameter("dbpass");
String dburl  = application.getInitParameter("dburl");

Conn con =new Conn(dbuser,dbpass,dburl);

String menu="4"; 
String  tmp="";

String act=request.getParameter("reg");
String nuname=(String)session.getAttribute("ookweb_user_username");

if("".equals(nuname) || nuname==null){
 response.sendRedirect(basePath+"ookweb/login.jsp");
}

String username="",userpass="",truename="",company="",telephone="",email="",question="",answer="";
username=nuname;
 String sql="";
if("start".equals(act)){

  Data data=new Data(dbuser,dbpass,dburl);
	userpass=request.getParameter("password1");
	truename=request.getParameter("true_name");
out.print(userpass);
	company=request.getParameter("com_name");
	telephone=request.getParameter("addr");
	email=request.getParameter("email");
	question=request.getParameter("question");
	answer=request.getParameter("answer");
	userpass=userpass.trim();
	if(!("".equals(userpass) || userpass==null)){
	sql="update  web_member set  userpass='"+userpass+"',truename='"+truename+"',company='"+company+"',telephone='"+telephone+"',email='"+email+"',question='"+question+"',answer='"+answer+"' where username='"+nuname+"'";
	}else{
	sql="update  web_member set truename='"+truename+"',company='"+company+"',telephone='"+telephone+"',email='"+email+"',question='"+question+"',answer='"+answer+"' where username='"+nuname+"'";
	}

  int num=data.update(sql);
}
 sql="select * from web_member where username='"+nuname+"'";
   ResultSet rsv=con.getRs(sql);
   if(rsv.next()){
	truename=rsv.getString("truename");
	company=rsv.getString("company");
	telephone=rsv.getString("telephone");
	email=rsv.getString("email");
	question=rsv.getString("question");
	answer=rsv.getString("answer");
   }
%>
     <%@ include file="/menu.jsp" %> 
     <div class="div8"></div>
     <table width="100%" border="0" cellpadding="0" cellspacing="0">
       <tr>
         <td align="center" valign="top">
           <table width="100%" height="627" border="0" cellpadding="0" cellspacing="0">
             <tr >
               <td align="left" valign="top" >
               <table width="100%" border="0">
                  <tr>
                    <td style=" background:url(images/msg.gif) no-repeat" height="38"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="10%" height="26" align="center" style=" color:#333333; font-size:14px; font-weight:bold;">&nbsp;&nbsp;留言板</td>
                        <td width="57%">&nbsp;</td>
                        <td width="33%" align="right" class="hui12">首页-&gt;留言板</td>
                      </tr>
                    </table></td>
                  </tr>
                </table>
                <div style=" font-size:12px; color:#999999; border-bottom:1px dashed #CCCCCC">&nbsp;&nbsp;&nbsp;&nbsp;欢迎登录东方通网站</div><br>
                <table width="100%" border="0" cellpadding="8" align="right">
	      <tr>
             <td width="22%" height="181" align="center" valign="top" >
               <table width="120" border="0" cellpadding="0" cellspacing="0">
                 <tr>
                   <td style=" height:26px; color:#666666;  font-size:14px; line-height:26px;font-weight:bold; vertical-align:middle; border-bottom:1px solid #9C9C9C"><a href="userinfo.jsp" style="color:#cccccc;text-decoration:none; font-size:14px;">我的个人资料</a></td>
                 </tr>
                 <tr>
                   <td  style=" height:26px; color:#666666;font-size:14px; line-height:26px;vertical-align:middle;border-bottom:1px solid #9C9C9C"><a href="msg.jsp" style="color:#cccccc; text-decoration:none;font-size:14px;">我的疑问解答</a></td>
                 </tr>
                 <tr>
                   <td  style=" height:26px; color:#666666;font-size:14px; line-height:26px;vertical-align:middle;border-bottom:1px solid #9C9C9C"><a href="sub.jsp" style="color:#cccccc;text-decoration:none;font-size:14px;">我要提问</a></td>
                 </tr>
               </table></td>
             <td width="78%" valign="top" class="infolist"><table width="542" border="0" cellpadding="0" cellspacing="0">
               <tr>
                 <td><img src="images/ucarea.gif" width="545" height="22" /></td>
               </tr>
               <tr align="center">
                 <td height="288" valign="top" background="images/ucbj.gif"><table width="96%" border="0" cellpadding="0" cellspacing="0">
                   <tr style=" border-bottom:1px solid #999999;">
                     <td width="23%" height="37" align="right" style=" border-bottom:1px solid #999999;"> <span class="STYLE3">我的个人资料</span></td>
                     <td width="77%" style=" border-bottom:1px solid #999999;">&nbsp;</td>
                   </tr>
                   <tr>
                     <td colspan="2"> 这是你当前的个人信息，根据需要更新你的个人资料。</td>
                   </tr>
                   <tr>
                     <td colspan="2">&nbsp;</td>
                   </tr>
                   <tr>
                     <td colspan="2">
                      <form name="form1" method="post" action="<%=basePath%>ookweb/userinfo.jsp" onSubmit="return CheckForm();">
                      <input name="reg" type="hidden" value="start" />
                     <table width="90%" border="0" align="center" cellpadding="4" cellspacing="0">
                       <tbody>
                         <tr height="28">
                           <td width="34%" height="35" align="right" bgcolor="#FFFFFF" ><strong>用户名：</strong><br /></td>
                           <td width="66%" height="35" bgcolor="#FFFFFF"  align="left" ><%=username %></td>
                         </tr>
                         <tr>
                           <td width="34%" height="35" align="right" bgcolor="#FFFFFF" ><strong>密码：</strong><br /></td>
                           <td height="35" bgcolor="#FFFFFF"  align="left"><input   name="password1"  type="password" class="input"  id="password1"/> 注:不修改可不填</td>
                         </tr>
                         <tr>
                           <td height="35" align="right" bgcolor="#FFFFFF" ><strong>密码确认：</strong><br /></td>
                           <td height="35" bgcolor="#FFFFFF"  align="left"><input  name="password2" type="password" class="input"  id="password2"/> 注:不修改可不填</td>
                         </tr>
                         <tr height="28">
                           <td width="34%" height="35" align="right" bgcolor="#FFFFFF" ><strong>真实姓名：</strong><br />
                           </td>
                           <td height="35" bgcolor="#FFFFFF"  align="left"><input name="true_name"  type="text" class="input" id="true_name" value="<%=truename %>"/>
                               <span id="nameinfo"></span></td>
                         </tr>
                         <tr height="28">
                           <td width="34%" height="35" align="right" bgcolor="#FFFFFF" ><strong>公司名称：</strong><br />
                           </td>
                           <td height="35" bgcolor="#FFFFFF"  align="left"><input name="com_name"  type="text" class="input" id="com_name" value="<%=(company==null)?"":company %>"/>
                               <span id="nameinfo"></span></td>
                         </tr>
                         <tr height="28">
                           <td width="34%" height="35" align="right" bgcolor="#FFFFFF" ><strong>联系方式：</strong><br />
                           </td>
                           <td height="35" bgcolor="#FFFFFF"  align="left"><input name="addr"  type="text" class="input" id="addr" value="<%=(telephone==null)?"":telephone %>"/>
                               <span id="nameinfo"></span></td>
                         </tr>
                         <tr>
                           <td height="35" align="right" bgcolor="#FFFFFF" ><strong>E_mail地址</strong><strong>：</strong><br /></td>
                           <td height="35" bgcolor="#FFFFFF"  align="left"><input  name="email"  type="text" class="input" id="email" value="<%=email %>"/></td>
                         </tr>
                         <tr>
                           <td height="35" align="right" bgcolor="#FFFFFF" ><strong>密码提示问题</strong><strong>：</strong><br /></td>
                           <td height="35" bgcolor="#FFFFFF"  align="left"><input name="question" type="text" class="input" value="<%=question %>"/></td>
                         </tr>
                         <tr>
                           <td height="35" align="right" bgcolor="#FFFFFF" ><strong>密码问题答案</strong><strong>：</strong><br /></td>
                           <td height="35" bgcolor="#FFFFFF"  align="left"><input name="answer" type="text" class="input" value="<%=answer %>"/>
                           </td>
                         </tr>
                         <tr>
                           <td height="35" colspan="2" bgcolor="#FFFFFF"><div align="center">
                               <input name="postreg" type="submit" class="cmd" value="提交" />
                             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                             <input name="resetreg" type="reset" class="cmd" value="重置" />
                           </div></td>
                         </tr>
                       </tbody>
                     </table>
                     </form>
                     </td>
                   </tr>
                 </table></td>
               </tr>
               <tr>
                 <td><img src="images/ucareabot.gif" width="545" height="22" /></td>
               </tr>
             </table>
               <script language="javascript" type="text/javascript">
function CheckForm(){
	var iu, iuu, regArray=new Array("","???","???","???","???","???","???","???"+
	"!","@","#","$","%","^","&","*","(",")","-","+","=","|","'","[","]","???","~","`"+
	"!","<",">","???","???","???","???","???","??","??"); 
	iuu=regArray.length;
	
	
	if (document.forms[0].password1.value.length>0) {
		if (document.forms[0].password1.value.length<6) {
			alert("密码长度不应该小于6.");
			document.forms[0].password1.focus();
			return false;
		}
		if (document.forms[0].password2.value.length==0){
			alert("确认密码长度不能够等于零");
			document.forms[0].password2.focus();
			return false;
		}
		if (document.forms[0].password1.value != document.forms[0].password2.value) {
			alert("两次密码不一致.");
			document.forms[0].password1.focus();
			return false;
		}
	}
	for(iu=1;iu<=iuu;iu++){
		if (document.forms[0].true_name.value.indexOf(regArray[iu])!=-1){
			alert("真实姓名不能够包含字符：" + regArray[iu]);
			document.forms[0].true_name.focus();
			return false;
		}
	}
	if (document.forms[0].true_name.value.length==0) {
		alert("真实姓名不能够为空.");
		document.forms[0].true_name.focus();
		return false;
	}
	if (document.forms[0].true_name.value.indexOf(" ")!=-1){
		alert("真实姓名不能够包含空格");
		document.forms[0].true_name.focus();
		return false;
	}
	if (document.forms[0].com_name.value.length==0) {
		alert("公司名称不能够为空.");
		document.forms[0].com_name.focus();
		return false;
	}
		if (document.forms[0].com_name.value.indexOf(" ")!=-1){
		alert("公司名称不能够包含空格");
		document.forms[0].com_name.focus();
		return false;
	}
	if (document.forms[0].addr.value.length==0) {
		alert("联系方式不能够为空.");
		document.forms[0].addr.focus();
		return false;
	}
		if (document.forms[0].addr.value.indexOf(" ")!=-1){
		alert("联系方式不能够包含空格");
		document.forms[0].addr.focus();
		return false;
	}
	if (document.forms[0].email.value.length==0) {
		alert("E_mail长度不能够等于零.");
		document.forms[0].email.focus();
		return false;
	}
	if (document.forms[0].email.value.length>0 && !document.forms[0].email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) ) {
		alert("请填写正确的E_mail地址");
		document.forms[0].email.focus();
		return false;
	}
	if (document.forms[0].question.value.length>20) {
		alert("密码提示问题长度不能够大于20.");
		document.forms[0].question.focus();
		return false;
	}
	if (document.forms[0].answer.value.length>20) {
		alert("密码问题答案长度不能够大于20.");
		document.forms[0].answer.focus();
		return false;
	}
	return true;
} 
</script>
               </td>
	      </tr>
     </table>

               </td>
               </tr>
           </table></td>
         </tr>
     </table>     

        <%@ include file="/right.jsp" %>
</div>